package com.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;

//@Configuration
//@EnableWebSecurity
public class SecurityConfig01 {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http.csrf(Customizer.withDefaults()) // 防止csrf攻击
                // 授权，认证
                .authorizeRequests(auth -> {
                    auth.anyRequest().authenticated();
                })
                // 最基本认证
//                .httpBasic()
//                .and()
                // 默认的表单登录
                .formLogin(Customizer.withDefaults())
        ;

        return http.build();
    }

}